#ifndef __FUNCTION_H
#define __FUNCTION_H

#include <ctime>
#include <iostream>
#include <QString>
#include <vector>
#include <unordered_map>
#include <QMap>
#include <QList>
#include <QString>


class Ticket {
public:
    QString ticket_type;
    double price;
    // 提供默认构造函数
    Ticket() : ticket_type("Unknown"), price(0.0) {}
    // 带参数的构造函数
    Ticket(QString ticket_type, double price)
        : ticket_type(ticket_type), price(price) {}
};

class Attraction {
public:
    QString name;
    QString description;
    QMap<QString, Ticket> ticket_types; // 根据身份证明类型设置票价
    int daily_limit;
    int booked_today;

    Attraction(QString name, QString description, int daily_limit, int today, double full, double half);

    void show_info();
    bool can_book();
    void book_ticket();
    void cancel_ticket();
};

class Visitor {
public:
    QString username;
    QString name;
    QString contact;
    QString id_card;
    QString id_type; // 身份证明类型
    bool is_admin;  // 判断是否为管理员

    Visitor(QString username, QString name, QString contact, QString id_card,
            QString id_type, bool is_admin);
};

class System {
public:
    QList<Visitor> visitors;
    QList<Attraction> attractions;
    QMap<QString, Visitor *> logged_in_users;

public:
    System();
    // 游客注册
    void register_visitor(QString username, QString name, QString contact, QString id_card,
                          QString id_type, bool is_admin) ;
    // 游客登录
    Visitor *login(QString user);
    // 预约景点票
    void book_ticket(Visitor *visitor);
    // 取消预约
    void cancel_ticket(Visitor *visitor);
    // 显示景点信息
    void show_attractions();
    // 管理员统计信息
    void admin_statistics();
};

#endif
